package com.drug.controller;

import com.drug.domain.DrugAtegory;
import com.drug.domain.Result;
import com.drug.service.DrugAtegoryService;
import com.drug.service.DrugInformationSerice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.SQLOutput;
import java.util.Map;

/**
 * 药品品目表控制层
 */
@Controller
@RequestMapping("/DrugAtegoryController")
public class DrugAtegoryController {

    @Autowired
    private DrugAtegoryService drugAtegoryService;

    @Autowired
    private DrugInformationSerice drugInformationSerice;

    /**
     * 新增药品品目
     */
    @ResponseBody
    @RequestMapping(value = "/fandAllDrugAtegory", produces = "application/json; charset=utf-8")
    public Result addDrugAtegory(@RequestParam Map<String,Object> map){
        Integer daId= drugAtegoryService.addDrugAtegory(map);
        map.put("daId",daId);

        Result result = drugInformationSerice.addDrugInformation(map);

        return result;
    }


    /**
     * 查询商品名是否已存在
     * @param daName
     * @return
     */
    @ResponseBody
    @RequestMapping("/findspName")
    public Result daName(String daName){
        return drugAtegoryService.daName(daName);
    }

}
